<?php
use yii\helpers\Url;
?>
<style>
    .mui-input-group {
        margin-top: 10px;
    }

    .mui-input-group:first-child {
        margin-top: 20px;
    }

    .mui-input-group label {
        width: 22%;
    }

    .mui-input-row label~input,
    .mui-input-row label~select,
    .mui-input-row label~textarea {
        width: 78%;
    }
</style>
<div class="login-portrait">
    <img src="/images/login.png" />
</div>
<form id='login-form' class="mui-input-group">
    <div class="mui-input-row">
        <label>账号</label>
        <input id='account' type="text" name="name" class="mui-input-clear mui-input" placeholder="请输入账号">
    </div>
    <div class="mui-input-row">
        <label>密码</label>
        <input id='password' name="password" type="password" class="mui-input-clear mui-input" placeholder="请输入密码">
    </div>
</form>
<div class="mui-content-padded">
    <button id='login' class="mui-btn mui-btn-block mui-btn-primary" style="padding:6px 0;">登录</button>
    <div class="link-area"><a id='reg' href="<?php echo Url::toRoute("site/signup"); ?>">注册账号</a> 
    </div>
</div>
<script>
    (function ($, doc) {
        $.init({
            statusBarBackground: '#f7f7f7'
        });
        //检查 "登录状态/锁屏状态" 结束
        var loginButton = doc.getElementById('login');
        var accountBox = doc.getElementById('account');
        var passwordBox = doc.getElementById('password');
        loginButton.addEventListener('tap', function (event) {
            var loginInfo = {
                account: accountBox.value,
                password: passwordBox.value
            };
            app.login(loginInfo, function (err) {
                if (err) {
                    mui.toast(err);
                    return;
                }
                 window.location.herf = "/site/index.html";
            });
        });
    }(mui, document));
</script>